<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<script src="/static/js/jquery/jquery.min.js"></script>
</head>
<body>
	
	你好${pagename!"aa"}
	<img src="/1.png"/>
	
	
	<form>
		商品数量：<input id="goodnum"/><br/>
		订单价格：<input id="price"/><br/>
		<input type="button" value="增加" onclick="addOrder()"/>
	</form>
	
	<br/>
	<br/>
	
	订单编号：<input id="orderid"/><br/>
	<input type="button" value="查询" onclick="getOrder()"/>

	<br/>
	<br/>
	
	订单编号：<input id="orderid_del"/><br/>
	<input type="button" value="删除" onclick="delOrder()"/>
	
	<br/>
	<br/>
	<form>
		订单编号：<input id="orderid_edit"/><br/>
		商品数量：<input id="goodnum_edit"/><br/>
		订单价格：<input id="price_edit"/><br/>
		<input type="button" value="修改" onclick="editOrder()"/>
	</form>
	
	<script>
		
		
		var addOrder = function(){
			console.log(11);
			var price = $("#price").val();
			var goodnum = $("#goodnum").val();
			$.ajax({
			   type: "POST",
			   url: "/app/api/v3/orders",
			   data: "price="+price+"&goodnum="+goodnum,
			   success: function(msg){
			     alert( "Data Saved: " + msg.code+","+msg.msg);
			   }
			});
		}
		
		
		var getOrder = function(){
			var orderid = $("#orderid").val();
			$.ajax({
			   type: "GET",
			   url: "/app/api/v3/orders/"+orderid,
			   success: function(msg){
			     var data = msg.data.users;
			     
			     console.log(data[0].username);
			     console.log(data[0].userpwd);
			     
			   }
			});
		}
		
		
		var delOrder = function(){
			var orderid = $("#orderid_del").val();
			$.ajax({
			   type: "DELETE",
			   url: "/app/api/v3/orders/"+orderid,
			   success: function(msg){
					
			     console.log( "Data Saved: " + msg.code+","+msg.msg);

			   }
			});
		}
		
		var editOrder = function(){
			var orderid = $("#orderid_edit").val();
			var price = $("#price_edit").val();
			var goodnum = $("#goodnum_edit").val();
			$.ajax({
			   type: "PUT",
			   url: "/app/api/v3/orders/"+orderid,
			   data: {"price":price,"goodnum":goodnum},
			   success: function(msg){
			     alert( "Data Saved: " + msg.code+","+msg.msg);
			   }
			});
		}
		
		
		
	</script>
	
	
</body>
</html>
